package com.enroll.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="subject")
public class Subject {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	private String name;
	private int unit;
	
	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(name="STUDENT_SUBJECT",joinColumns={@JoinColumn(name="subject_id")},
									  inverseJoinColumns={@JoinColumn(name="student_id")}
	)
	private Set<Student> students = new HashSet<Student>();
	 
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "FACULTY_ID", nullable = false)
	private Faculty faculty;
	
	
	public Integer getId() {
		return id;
	}
	public Faculty getFaculty() {
		return faculty;
	}
	public void setFaculty(Faculty faculty) {
		this.faculty = faculty;
	}
	public Set<Student> getStudents() {
		return students;
	}
	public void setStudents(Set<Student> students) {
		this.students = students;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getUnit() {
		return unit;
	}
	public void setUnit(int unit) {
		this.unit = unit;
	}
	
	
	
}
